﻿using System;
using MoonSharp.Interpreter;
using UnityEngine;

namespace Lua
{
	// Token: 0x020002EA RID: 746
	[MoonSharpUserData]
	public class AudioSource
	{
		// Token: 0x06001165 RID: 4453 RVA: 0x0007F764 File Offset: 0x0007D964
		[MoonSharpHidden]
		public AudioSource(Transform transform)
		{
			if (transform == null)
			{
				Debug.Log("No transform.");
			}
			this.customSource = transform._tf.GetComponent<CustomAudioSource>();
			if (this.customSource == null)
			{
				this.customSource = transform._tf.gameObject.AddComponent<CustomAudioSource>();
			}
			if (AudioSource.ioManager == null)
			{
				AudioSource.ioManager = IOManager.Instance;
			}
		}

		// Token: 0x06001166 RID: 4454 RVA: 0x0007F7D9 File Offset: 0x0007D9D9
		public static AudioSource New(Entity entity)
		{
			return new AudioSource(entity.transform);
		}

		// Token: 0x06001167 RID: 4455 RVA: 0x0007F7E6 File Offset: 0x0007D9E6
		public static AudioSource New(Transform transform)
		{
			return new AudioSource(transform);
		}

		// Token: 0x17000274 RID: 628
		// (get) Token: 0x06001168 RID: 4456 RVA: 0x0007F7EE File Offset: 0x0007D9EE
		// (set) Token: 0x06001169 RID: 4457 RVA: 0x0007F7FB File Offset: 0x0007D9FB
		public float maxDistance
		{
			get
			{
				return this.customSource.maxDistance;
			}
			set
			{
				this.customSource.maxDistance = value;
			}
		}

		// Token: 0x17000275 RID: 629
		// (get) Token: 0x0600116A RID: 4458 RVA: 0x0007F809 File Offset: 0x0007DA09
		// (set) Token: 0x0600116B RID: 4459 RVA: 0x0007F816 File Offset: 0x0007DA16
		public float minDistance
		{
			get
			{
				return this.customSource.minDistance;
			}
			set
			{
				this.customSource.minDistance = value;
			}
		}

		// Token: 0x17000276 RID: 630
		// (get) Token: 0x0600116C RID: 4460 RVA: 0x0007F824 File Offset: 0x0007DA24
		// (set) Token: 0x0600116D RID: 4461 RVA: 0x0007F83B File Offset: 0x0007DA3B
		public string clip
		{
			get
			{
				return this.customSource.audioSource.clip.name;
			}
			set
			{
				this.customSource.audioSource.clip = AudioSource.GetClip(value);
			}
		}

		// Token: 0x0600116E RID: 4462 RVA: 0x0007F853 File Offset: 0x0007DA53
		private static AudioClip GetClip(string clipName)
		{
			if (AudioSource.ioManager == null)
			{
				AudioSource.ioManager = IOManager.Instance;
			}
			return AudioSource.ioManager.LoadAudioClip(clipName);
		}

		// Token: 0x17000277 RID: 631
		// (get) Token: 0x0600116F RID: 4463 RVA: 0x0007F87A File Offset: 0x0007DA7A
		public bool isPlaying
		{
			get
			{
				return this.customSource.audioSource.isPlaying;
			}
		}

		// Token: 0x17000278 RID: 632
		// (get) Token: 0x06001170 RID: 4464 RVA: 0x0007F88C File Offset: 0x0007DA8C
		// (set) Token: 0x06001171 RID: 4465 RVA: 0x0007F89E File Offset: 0x0007DA9E
		public bool loop
		{
			get
			{
				return this.customSource.audioSource.loop;
			}
			set
			{
				this.customSource.audioSource.loop = value;
			}
		}

		// Token: 0x17000279 RID: 633
		// (get) Token: 0x06001172 RID: 4466 RVA: 0x0007F8B1 File Offset: 0x0007DAB1
		// (set) Token: 0x06001173 RID: 4467 RVA: 0x0007F8C3 File Offset: 0x0007DAC3
		public bool mute
		{
			get
			{
				return this.customSource.audioSource.mute;
			}
			set
			{
				this.customSource.audioSource.mute = value;
			}
		}

		// Token: 0x1700027A RID: 634
		// (get) Token: 0x06001174 RID: 4468 RVA: 0x0007F8D6 File Offset: 0x0007DAD6
		// (set) Token: 0x06001175 RID: 4469 RVA: 0x0007F8E8 File Offset: 0x0007DAE8
		public float pitch
		{
			get
			{
				return this.customSource.audioSource.pitch;
			}
			set
			{
				this.customSource.audioSource.pitch = value;
			}
		}

		// Token: 0x1700027B RID: 635
		// (get) Token: 0x06001176 RID: 4470 RVA: 0x0007F8FB File Offset: 0x0007DAFB
		// (set) Token: 0x06001177 RID: 4471 RVA: 0x0007F90D File Offset: 0x0007DB0D
		public float spatialBlend
		{
			get
			{
				return this.customSource.audioSource.spatialBlend;
			}
			set
			{
				this.customSource.audioSource.spatialBlend = value;
			}
		}

		// Token: 0x1700027C RID: 636
		// (get) Token: 0x06001178 RID: 4472 RVA: 0x0007F920 File Offset: 0x0007DB20
		// (set) Token: 0x06001179 RID: 4473 RVA: 0x0007F932 File Offset: 0x0007DB32
		public float volume
		{
			get
			{
				return this.customSource.audioSource.volume;
			}
			set
			{
				this.customSource.audioSource.volume = value;
			}
		}

		// Token: 0x0600117A RID: 4474 RVA: 0x0007F945 File Offset: 0x0007DB45
		public void Pause()
		{
			this.customSource.audioSource.Pause();
		}

		// Token: 0x0600117B RID: 4475 RVA: 0x0007F957 File Offset: 0x0007DB57
		public void Play()
		{
			this.customSource.Play();
		}

		// Token: 0x0600117C RID: 4476 RVA: 0x0007F964 File Offset: 0x0007DB64
		public void PlayDelayed(float delay)
		{
			this.customSource.PlayDelayed(delay);
		}

		// Token: 0x0600117D RID: 4477 RVA: 0x0007F972 File Offset: 0x0007DB72
		public void PlayOneShot(string clip, float volumeScale)
		{
			this.customSource.PlayOneShot(AudioSource.GetClip(clip), volumeScale);
		}

		// Token: 0x0600117E RID: 4478 RVA: 0x0007F986 File Offset: 0x0007DB86
		public void PlayOneShot(string clip)
		{
			this.customSource.PlayOneShot(AudioSource.GetClip(clip));
		}

		// Token: 0x0600117F RID: 4479 RVA: 0x0007F999 File Offset: 0x0007DB99
		public void Stop()
		{
			this.customSource.audioSource.Stop();
		}

		// Token: 0x06001180 RID: 4480 RVA: 0x0007F9AB File Offset: 0x0007DBAB
		public void UnPause()
		{
			this.customSource.audioSource.UnPause();
		}

		// Token: 0x06001181 RID: 4481 RVA: 0x0007F9BD File Offset: 0x0007DBBD
		public static void PlayClipAtPoint(string clip, Vector3 position, float volume)
		{
			AudioSource.PlayClipAtPoint(AudioSource.GetClip(clip), position.vector3.ToWorld(), volume);
		}

		// Token: 0x06001182 RID: 4482 RVA: 0x0007F9D8 File Offset: 0x0007DBD8
		public static float GetClipLength(string clip)
		{
			AudioClip clip2 = AudioSource.GetClip(clip);
			if (!clip2 || clip2.loadState != AudioDataLoadState.Loaded)
			{
				return -1f;
			}
			return clip2.length;
		}

		// Token: 0x040016B4 RID: 5812
		private CustomAudioSource customSource;

		// Token: 0x040016B5 RID: 5813
		private static IOManager ioManager;
	}
}
